﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Most frequent number</title>
    <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <div id="js-console"></div>
	<script src="scripts/js-console.js"></script>

    <script>
        var max = 0;
        var maxCount = 0;
        var current = 0;
        var currentCount = 1;
        var arr = [1,1,1,2,2,2,2,2,3,3,3,3];

        for (var i = 0; i < arr.length; i++) {

            currentCount = 1;
            current = arr[i];
            for (var j = i + 1; j < arr.length; j++) {
        
                if (current == arr[j]) {
                
                    currentCount++;
                }
            }
            if (maxCount < currentCount) {
        
                max = current;
                maxCount = currentCount;
            }
        }
        jsConsole.write("number "+ max+ "==>" + "times" );
    </script>
</body>
</html>
